{% extends "base.html" %}
{% block title %}{{ product['name'] }}{% end %}

{% block js %}
	<script src="{{ static_url('js/jquery.cj-object-scaler.min.js') }}" type="text/javascript"></script>
        <script src="{{ static_url('js/jquery.lazyload.min.js') }}" type="text/javascript"></script>
        <script src="{{ static_url('js/jquery.rating.min.js') }}" type="text/javascript"></script>
        <script src="{{ static_url('js/jquery.fcbkcomplete.min.js') }}" type="text/javascript"></script>
	<script src="{{ static_url('js/textarea.js') }}" type="text/javascript"></script>
	<script type="text/javascript">
		$(function(){
			$('.p_img').each(function() {
                            $(this).cjObjectScaler({method: "fit"});
                             
			     $('input.star').rating({% if has_rated %}'select', '{{ rate['rate'] }}'{% end %});
                             
			     $("#select3").fcbkcomplete({
                                json_url: "{{ reverse_url('dummy') }}",
                                addontab: true,
                                height: 2,
				newel: true
                            });
			    
			    $('#wxm_sina').click(function(){
				window.open('http://v.t.sina.com.cn/share/share.php?title={{ product["name"] }}'); 
			    });
			    
			    $('.clickable').click(function(){
				var reply_content = document.getElementById('comment');
				user = $(this).attr('alt');
				TA.add(reply_content, ' @'+user+' ')
			    });
			    
                        });
		});
	</script>
{% end %}


{% block right %}

{% end %}

{% block content %}
            <div class="box"> 
                <div class="cell">
		    <span class="bigger">
			<a href="{{ reverse_url('main') }}">{{ handler.settings.site_name }}</a>
			<span class="chevron"> › </span>
			<a href="{{ reverse_url('fg') }}">富光</a>
			<span class="chevron"> › </span>
			{{ product['name'] }}
		    </span>
		    <div class="sep10"></div>
		    <div>
                    <table cellpadding="0" cellspacing="0" width="100%" border="0">
                        <tr>
                            <td width="150" valign="top">
                                <div style="width:148px;height:180px;">
                                    <img src="{{ product['image'] }}" class="p_img" />
                                </div>
                            </td>
                            <td width="10"></td>
                            <td width="auto" align="left" valign="top">
                                <div class="fr">
                                    <div class="sep3"></div>
                                    <a href="#" class="super special button">获取优惠</a>
                                </div>
                                <h2 style="line-height: 22px;">{{ product['name'] }}</h2>
                                <a href="{{ product['url'] }}" target="about" class="op">官方网站相关</a>
                                <div class="sep5"></div>
                                <span class="fade">
                                    {{ modules.Escape(product['desc'].replace('|', '')) }}
                                </span>
                                <div class="sep10"></div>
				<span class="fade">
					{% if rate_data %}
					评价: {{ int(rate_data['rate_count']) }} 次<br/>
					平均分:{{ rate_data['avg'] }} 分<br/>
					标签: {% for t in rate_data['tags'] %}<a href="{{ reverse_url('tag', t[0] ) }}">{{ t[0] }}</a> ({{ t[1] }}) &nbsp;&nbsp;{% end %}<br/>
					(本结果缓存10分钟)
					{% else %}
					还没有人评论过.
					{% end %}
				</span>
				<div align="right">
					<img id="wxm_sina" style="cursor:pointer;" title="将选中内容分享到新浪微博" src="http://simg.sinajs.cn/blog7style/images/common/share.gif" />
				</div>
                            </td>
                        </tr>
                    </table>
		    </div>
                </div>
                <div class="inner">
                    <div style="margin:10px;padding:10px;border:solid 1px #dbdbdb">
			<h4>我的评价</h4>
			<form action="" method="POST">
			{{ xsrf_form_html() }}
			<table cellpadding="0" cellspacing="0" width="100%" border="0">
				<tr>
					<td>
						评分
					</td>
					<td>
						<div id="rate" style="height:30px;">
							<input name="star2" type="radio" class="star" value="1"/>
							<input name="star2" type="radio" class="star" value="2"/>
							<input name="star2" type="radio" class="star" value="3"/>
							<input name="star2" type="radio" class="star" checked="checked" value="4"/>
							<input name="star2" type="radio" class="star" value="5"/>
							<input name="star2" type="radio" class="star" value="6"/>
							<input name="star2" type="radio" class="star" value="7"/>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						标签
					</td>
					<td>
						<div id="tags" style="clear:both;">
							<select id="select3" name="select3">
							{% if has_rated %}
							    {% for t in rate['tags'] %}
							    <option value="{{ t }}" class="selected">{{ t }}</option>
							    {% end %}
							{% end %}
							</select>
						</div>
					</td>
				</tr>
		
				<tr>
					<td>
						
					</td>
					<td>
						<input type="hidden" value="ratentag" name="k"/>
						<input type="submit" value="保存" class="super normal button"/>
					</td>
				</tr>
			</table>
			</form>
                    </div>
                </div>
            </div>
            <div class="sep20"></div>
	    {% if has_comment %}
	    <div class="box">
		<div id="replies">
		{% for c in comments %}
		{{ modules.Comment(c) }}
		{% end %}
		</div>
	    </div>
	    {% else %}
            <div class="glass" align="center">
                    <div class="inner">
                            <span>目前没有评论</span>
                    </div>
            </div>
            {% end %}
            {% if current_user %}
            <div class="sep20"></div>
            
            <div class="box">
                    <form action="" method="post">
                            {% if globals().get('error_msgs') %}
                            <strong>请补充、修改您填写的内容</strong>
                            <div class="sep10"></div>
                            <ul>
                                {% for error in error_msgs %}
                                <li>{{ error }}</li>
                                {% end %}
                            </ul>
                            {% end %}
                            <div class="cell">
                                    <div class="fr fade">
                                            <a href="#_top" class="dark">回到顶部</a>
                                    </div> 
                                    <span class="fade">添加一条评论</span>
                            </div> 
                            <div class="cell"> 
                                    <textarea class="mll" name="comment" id="comment"></textarea> 
                                    <div class="sep10"></div> 
                                    <div class="fr fade" id="e"></div>
				    <input type="hidden" value="comment" name="k"/>
                                    <input type="submit" class="super normal button" value="发送" />
                                    {{ xsrf_form_html() }}
                            </div>
                    </form>
               </div>
            {% end %}
            
            
{% end %}